package a.j;

import a.e.c;
import a.i.kb;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.awt.image.IndexColorModel;
import java.awt.image.MemoryImageSource;
import java.awt.image.PixelGrabber;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;

public class nd
  extends ld
{
  private static final Hashtable n = new Hashtable(11);
  private static final WeakHashMap F = new WeakHashMap(11);
  private static final Set G = new HashSet(11);
  private static OutputStream H = null;
  private static final Component I = new JLabel();
  private static final MediaTracker J = new MediaTracker(I);
  private URL K;
  private Image L;
  private BufferedImage M;
  private static final BufferedImage N;
  private static final double O = 1.0D;
  public static boolean P;
  
  public nd() {}
  
  public nd(ld paramld)
  {
    super(paramld);
    if ((ld.E) || ((paramld instanceof nd)))
    {
      nd localnd = (nd)paramld;
      this.L = localnd.L;
      this.M = localnd.M;
      this.K = localnd.K;
    }
  }
  
  public boolean f(double paramDouble1, double paramDouble2)
  {
    boolean bool = ld.E;
    if (!bool) {
      if (this.M != null)
      {
        paramDouble1 -= a();
        paramDouble2 -= b();
        paramDouble1 *= this.M.getWidth() / c();
        paramDouble2 *= this.M.getHeight() / d();
        if (!bool) {
          if (paramDouble1 >= 0.0D)
          {
            if (bool) {
              break label156;
            }
            if (paramDouble2 >= 0.0D)
            {
              if (bool) {
                break label156;
              }
              if (paramDouble1 < this.M.getWidth())
              {
                if (bool) {
                  break label156;
                }
                if (paramDouble2 < this.M.getHeight())
                {
                  if (!bool) {}
                  return (this.M.getRGB((int)paramDouble1, (int)paramDouble2) >> 24 & 0xFF) > 127;
                }
              }
            }
          }
        }
        label156:
        return false;
      }
    }
    return super.f(paramDouble1, paramDouble2);
  }
  
  public void a(boolean paramBoolean)
  {
    b(paramBoolean);
    Q();
    R();
  }
  
  private void b(boolean paramBoolean)
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    if (!bool2)
    {
      if (!paramBoolean)
      {
        if (bool2) {
          break label35;
        }
        this.M = null;
      }
    }
    else if (!bool1) {
      return;
    }
    label35:
    if ((bool2) || (this.L == null))
    {
      this.M = N;
      return;
    }
    synchronized (F)
    {
      this.M = ((BufferedImage)F.get(this.L));
    }
    if ((bool2) || (this.M == null))
    {
      if (!bool2) {
        if (this.L == null)
        {
          this.M = N;
          if ((!bool2) && (!bool1)) {
            return;
          }
        }
      }
      if (!bool2) {
        if ((this.L instanceof BufferedImage))
        {
          this.M = ((BufferedImage)this.L);
          if ((!bool2) && (!bool1)) {
            return;
          }
        }
      }
      int i = (int)(this.L.getWidth(I) * 1.0D);
      int j = (int)(this.L.getHeight(I) * 1.0D);
      if ((bool2) || ((i > 0) && (j > 0)))
      {
        BufferedImage localBufferedImage1 = new BufferedImage(i, j, 2);
        Graphics2D localGraphics2D1 = localBufferedImage1.createGraphics();
        localGraphics2D1.drawImage(this.L, AffineTransform.getScaleInstance(1.0D, 1.0D), null);
        localGraphics2D1.setComposite(AlphaComposite.getInstance(5, 1.0F));
        localGraphics2D1.setColor(new Color(128, 128, 128));
        localGraphics2D1.fillRect(0, 0, i, j);
        localGraphics2D1.dispose();
        Color localColor1 = new Color(128, 128, 128, 0);
        Color localColor2 = new Color(0, 0, 0, 0);
        IndexColorModel localIndexColorModel = new IndexColorModel(1, 2, new byte[] { (byte)localColor2.getRed(), (byte)localColor1.getRed() }, new byte[] { (byte)localColor2.getGreen(), (byte)localColor1.getGreen() }, new byte[] { (byte)localColor2.getBlue(), (byte)localColor1.getBlue() }, 0);
        BufferedImage localBufferedImage2 = new BufferedImage(i, j, 13, localIndexColorModel);
        Graphics2D localGraphics2D2 = localBufferedImage2.createGraphics();
        try
        {
          localGraphics2D2.drawImage(localBufferedImage1, 0, 0, null, null);
        }
        finally
        {
          localGraphics2D2.dispose();
        }
        this.M = localBufferedImage2;
      }
      synchronized (F)
      {
        F.put(this.L, this.M);
      }
    }
  }
  
  public boolean e()
  {
    return this.M != null;
  }
  
  public ld a(ld paramld)
  {
    return new nd(paramld);
  }
  
  public static void a(String paramString1, String paramString2)
  {
    boolean bool = ld.E;
    URL localURL = kb.a(paramString1);
    if (!bool) {
      if (localURL != null)
      {
        if (bool) {
          break label35;
        }
        a(localURL);
        if (!ld.D) {
          return;
        }
      }
    }
    label35:
    a(kb.b(paramString2));
  }
  
  public static void a(URL paramURL)
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    try
    {
      if (paramURL == null) {
        return;
      }
      PropertyResourceBundle localPropertyResourceBundle = new PropertyResourceBundle(paramURL.openStream());
      String str1 = "";
      try
      {
        str1 = localPropertyResourceBundle.getString("basepath");
        if ((bool2) || (str1.length() > 0)) {
          str1 = str1 + '/';
        }
      }
      catch (MissingResourceException localMissingResourceException) {}
      if (str1.length() != 0)
      {
        localObject = new File(str1);
        if (!bool2) {
          if (!((File)localObject).isAbsolute())
          {
            if (bool2) {
              break label125;
            }
            paramURL = new URL(paramURL, str1);
            if (!bool1) {
              break label126;
            }
          }
        }
        label125:
        paramURL = ((File)localObject).toURL();
      }
      label126:
      Object localObject = localPropertyResourceBundle.getKeys();
      do
      {
        do
        {
          String str2;
          do
          {
            if (!((Enumeration)localObject).hasMoreElements()) {
              break;
            }
            str2 = (String)((Enumeration)localObject).nextElement();
          } while (str2.equals("basepath"));
          String str3 = localPropertyResourceBundle.getString(str2);
          URL localURL = new URL(paramURL, str3);
          b(localURL);
          if ((bool2) || ((!bool2) && (bool1))) {
            break;
          }
        } while (bool2);
      } while (!bool1);
    }
    catch (MalformedURLException localMalformedURLException)
    {
      n.a(localMalformedURLException);
    }
    catch (IOException localIOException)
    {
      n.a(localIOException);
    }
  }
  
  public static Image b(URL paramURL)
  {
    boolean bool = ld.E;
    if (!bool) {
      if (paramURL == null) {
        throw new NullPointerException("imageURL must not be null");
      }
    }
    Image localImage = (Image)n.get(paramURL);
    if (!bool) {
      if (localImage == null)
      {
        localImage = e(paramURL);
        if (bool) {
          break label64;
        }
        if (localImage != null) {
          n.put(paramURL, localImage);
        }
      }
    }
    label64:
    return localImage;
  }
  
  public static Vector f()
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    Vector localVector = new Vector(11);
    do
    {
      Enumeration localEnumeration = n.keys();
      while (!bool1)
      {
        if (!localEnumeration.hasMoreElements()) {
          break;
        }
        if (bool1) {
          break label58;
        }
        localVector.add(localEnumeration.nextElement());
      }
    } while (bool2);
    label58:
    return localVector;
  }
  
  public static Hashtable g()
  {
    return n;
  }
  
  public static Image c(URL paramURL)
  {
    return (Image)n.get(paramURL);
  }
  
  public void d(URL paramURL)
  {
    this.L = b(paramURL);
    this.K = paramURL;
    if (!ld.E)
    {
      if (this.M != null) {
        this.M = null;
      }
    }
    else {
      a(true);
    }
  }
  
  public void a(Image paramImage)
  {
    c(paramImage);
    this.L = paramImage;
    this.K = null;
    if (!ld.E)
    {
      if (this.M != null) {
        this.M = null;
      }
    }
    else {
      a(true);
    }
  }
  
  public Image h()
  {
    return this.L;
  }
  
  public URL i()
  {
    return this.K;
  }
  
  public void j()
  {
    if ((ld.E) || (h() != null)) {
      b(h().getWidth(null), h().getHeight(null));
    }
  }
  
  public void a(Graphics2D paramGraphics2D)
  {
    boolean bool = ld.E;
    if (!bool) {
      if (this.L != null) {
        paramGraphics2D.drawImage(this.L, (int)this.y, (int)this.z, (int)this.A, (int)this.B, null);
      }
    }
    if (!bool) {
      if (a(this, paramGraphics2D)) {
        b(paramGraphics2D);
      }
    }
    if (!bool) {
      if (c(paramGraphics2D, false)) {
        g(paramGraphics2D);
      }
    }
    if (a(paramGraphics2D, false)) {
      f(paramGraphics2D);
    }
  }
  
  public void a(ObjectOutputStream paramObjectOutputStream)
    throws IOException
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    if (!bool2)
    {
      if (e())
      {
        paramObjectOutputStream.writeByte(1);
        if (bool2) {
          break label60;
        }
      }
    }
    else {
      if (!bool1) {
        break label42;
      }
    }
    paramObjectOutputStream.writeByte(0);
    label42:
    if (!bool2)
    {
      super.a(paramObjectOutputStream);
      paramObjectOutputStream.writeObject(this.K);
      label60:
      if (H != paramObjectOutputStream)
      {
        G.clear();
        H = paramObjectOutputStream;
      }
    }
    if (!bool2)
    {
      if (this.K != null) {
        if (!bool2)
        {
          if (G.contains(this.K))
          {
            paramObjectOutputStream.writeBoolean(false);
            if (bool2) {
              break label131;
            }
          }
        }
        else if (!bool1) {
          return;
        }
      }
      paramObjectOutputStream.writeBoolean(true);
    }
    label131:
    if (!bool2) {
      if (this.L == null)
      {
        paramObjectOutputStream.writeInt(0);
        paramObjectOutputStream.writeInt(0);
        paramObjectOutputStream.write(new byte[0]);
        if ((!bool2) && (!bool1)) {
          return;
        }
      }
    }
    try
    {
      int i = this.L.getWidth(I);
      int j = this.L.getHeight(I);
      int[] arrayOfInt = new int[i * j];
      PixelGrabber localPixelGrabber = new PixelGrabber(this.L, 0, 0, i, j, arrayOfInt, 0, i);
      localPixelGrabber.grabPixels();
      paramObjectOutputStream.writeInt(i);
      paramObjectOutputStream.writeInt(j);
      byte[] arrayOfByte = new byte[arrayOfInt.length * 4];
      int k = 0;
      do
      {
        if (k >= arrayOfInt.length) {
          break;
        }
        int m = arrayOfInt[k];
        int i1 = k * 4;
        arrayOfByte[(i1 + 3)] = ((byte)(m & 0xFF));
        arrayOfByte[(i1 + 2)] = ((byte)(m >>> 8 & 0xFF));
        arrayOfByte[(i1 + 1)] = ((byte)(m >>> 16 & 0xFF));
        arrayOfByte[i1] = ((byte)(m >>> 24 & 0xFF));
        k++;
        if ((!bool2) && (bool1)) {
          break label361;
        }
      } while (!bool1);
      if (!bool2) {
        paramObjectOutputStream.write(arrayOfByte);
      }
      label361:
      if (this.K != null) {
        G.add(this.K);
      }
    }
    catch (InterruptedException localInterruptedException)
    {
      n.a("grabbing interrupted while serializing");
    }
  }
  
  public void a(ObjectInputStream paramObjectInputStream)
    throws IOException, ClassNotFoundException
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    int i = paramObjectInputStream.readByte();
    if (!bool2) {}
    switch (i)
    {
    case 0: 
    case 1: 
      super.a(paramObjectInputStream);
      if (!bool2)
      {
        this.K = ((URL)paramObjectInputStream.readObject());
        if (paramObjectInputStream.readBoolean())
        {
          int j = paramObjectInputStream.readInt();
          int k = paramObjectInputStream.readInt();
          byte[] arrayOfByte = new byte[j * k * 4];
          int m = 0;
          do
          {
            do
            {
              if (m >= arrayOfByte.length - 1) {
                break;
              }
              int i1 = paramObjectInputStream.read(arrayOfByte, m, arrayOfByte.length - m);
              if (bool1) {
                break label167;
              }
              if (i1 < 0) {
                throw new EOFException("Unexpected end of file");
              }
              m += i1;
            } while (!bool1);
          } while (bool2);
          int[] arrayOfInt = new int[j * k];
          int i2 = 0;
          do
          {
            if (i2 >= arrayOfInt.length) {
              break;
            }
            int i3 = i2 * 4;
            arrayOfInt[i2] = (((arrayOfByte[i3] & 0xFF) << 24) + ((arrayOfByte[(i3 + 1)] & 0xFF) << 16) + ((arrayOfByte[(i3 + 2)] & 0xFF) << 8) + ((arrayOfByte[(i3 + 3)] & 0xFF) << 0));
            i2++;
            if ((!bool2) && (bool1)) {
              break label296;
            }
          } while (!bool1);
          if (bool2) {
            break label361;
          }
          this.L = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(j, k, arrayOfInt, 0, j));
          if (!bool2) {
            if (this.K != null) {
              n.put(this.K, this.L);
            }
          }
          if (bool2) {
            break label365;
          }
          c(this.L);
          if (!bool1) {
            break label364;
          }
        }
      }
      if (!bool2) {
        if (this.K != null) {
          this.L = c(this.K);
        }
      }
      if (!bool2) {}
      a(i == 1);
      if (!bool1) {
        break;
      }
    default: 
      label167:
      label296:
      label361:
      label364:
      label365:
      throw new c();
    }
  }
  
  private static Image e(URL paramURL)
  {
    Image localImage = Toolkit.getDefaultToolkit().createImage(paramURL);
    localImage = c(localImage);
    return localImage;
  }
  
  private static Image c(Image paramImage)
  {
    synchronized (J)
    {
      J.addImage(paramImage, 0);
      try
      {
        J.waitForID(0, 5000L);
      }
      catch (InterruptedException localInterruptedException)
      {
        n.a("INTERRUPTED while loading Image");
      }
      int i = J.statusID(0, false);
      J.removeImage(paramImage, 0);
      switch (i)
      {
      case 2: 
        return null;
      case 4: 
        return null;
      }
      return paramImage;
    }
  }
  
  static
  {
    BufferedImage localBufferedImage;
    try
    {
      localBufferedImage = new BufferedImage(1, 1, 12);
    }
    catch (Exception localException)
    {
      localBufferedImage = new BufferedImage(8, 8, 2);
    }
    N = localBufferedImage;
    for (int i = 0; i < N.getHeight(); i++) {
      for (int j = 0; j < N.getWidth(); j++) {
        N.setRGB(j, i, Color.black.getRGB());
      }
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.j.nd

 * JD-Core Version:    0.7.0.1

 */